import es

from path import path as Path

"""
Significant Dates:

    01/08/2010: First major beta release
"""

class InfoManager(es.AddonInfo):
    """
    This class is a child class from the es.AddonInfo. Rather than making a new
    class of that directly, we shall make a direct copy of the AddonInfo which 
    in turn is a child of the dict class.
    
    This is only here to simulate our own info object with default parameters. 
    It is more OO than the usual method of instanting the es.AddonInfo class.
    """
    def __init__(self):
        """
        Default constructor, we need to execute a dictionary constructor passing
        the instance as a default parameter so we instantate the parent's parent
        class. We shall assign default values here which will make up our info.
        """
        dict.__init__(self)
        self.keylist  = ['name', 'version', 'url', 'basename', 'author']
        self.author   = "Freddukes (Steven Hartin)"
        self.basename = "wcs"
        self.name     = "WarCraft: Source"
        self.version  = WCS_VERSION
        self.url      = ("http://addons.eventscripts.com/addons/view/%s" %
                                                                self.basename)

""" Create the path defaults """
REVISION        = filter(str.isdigit, "$Revision: 54 $")
if not REVISION:
    REVISION = "000"
else:
    REVISION = "%03d" % int(REVISION)
WCS_VERSION     = "1.0.%s python" % REVISION
es.ServerVar("wcs_version", WCS_VERSION, 
             "The version of WarCraft: Source Python").makepublic()
info            = InfoManager()
WCS_PATH        = Path( es.getAddonPath(info.basename))
DATA_PATH       = WCS_PATH.joinpath("data")
EXTENSION_PATH  = WCS_PATH.joinpath("extension_folder")
LIB_PATH        = WCS_PATH.joinpath("libs")
RACE_PATH       = WCS_PATH.joinpath("race_folder")
SHOP_PATH       = WCS_PATH.joinpath("shopmenu")
GAME_EXTENSIONS = EXTENSION_PATH.joinpath("games")
IS_EST          = isEst = bool(es.ServerVar('est_version'))
IS_OB           = isOb = str(es.ServerVar('eventscripts_ver')).split('.')[1] == '1'
GAME_PATH       = Path(es.ServerVar('eventscripts_gamedir'))
CFG_PATH        = GAME_PATH.joinpath("cfg")
WCS_CFG_PATH    = CFG_PATH.joinpath("wcs")
RACE_CFG        = WCS_CFG_PATH.joinpath("races")
ADDON_PATH      = GAME_PATH.joinpath("addons")
DIRECTORY       = directory = GAME_PATH.splitpath()[1]

COLORS = {}
COLORS["red"]     = RED     = (255, 0,   0)
COLORS["blue"]    = BLUE    = (0,   0,   255)
COLORS["green"]   = GREEN   = (0,   255, 0)
COLORS["magenta"] = MAGENTA = (139, 0,   139)
COLORS["brown"]   = BROWN   = (128, 42,  42)
COLORS["grey"]    = GREY    = (128, 128, 128)
COLORS["cyan"]    = CYAN    = (0,   204, 204)
COLORS["yellow"]  = YELLOW  = (255, 255, 0)
COLORS["orange"]  = ORANGE  = (255, 127, 0)
COLORS["white"]   = WHITE   = (255, 255, 255)
COLORS["pink"]    = PINK    = (255, 0,   204)

try:
    LEVELUP_SOUND = {
      "cstrike" : "ambient/energy/whiteflash.wav",
      "hl2dm"   : "ambient/energy/whiteflash.wav",
      "dod"     : "ambient/energy/whiteflash.wav",
      "tf"      : "ambient/energy/whiteflash.wav",
      "pvkii"   : "ambient/energy/whiteflash.wav"
    }[DIRECTORY]
except KeyError:
    LEVELUP_SOUND = "ambient/energy/whiteflash.wav"
    
try:
    BLIP = {
       "cstrike" : "buttons/blip2.wav",
       "hl2dm"   : "weapons/slam/buttonclick.wav",
       "dod"     : "buttons/blip1.wav",
       "tf"      : "buttons/blip1.wav",
       "pvkii"   : "buttons/blip1.wav"
    }[DIRECTORY]
except KeyError:
    BLIP = "buttons/blip1.wav"